﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NewAI.Tools
{
    public class EasyTimestamp
    {
        private EasyTimestamp() { }

        public static double GetNowTimestamp()
        {
            TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
            return ts.TotalMilliseconds;
        }

        public static double GetTimestamp(DateTime dateTime)
        {
            TimeSpan ts = dateTime.ToUniversalTime() - new DateTime(1970, 1, 1);
            return ts.TotalMilliseconds;
        }

        private static double last = 0;
        public static void Init()
        {
            last = GetNowTimestamp();
        }

        public static int Time()
        {
            int time = (int)(GetNowTimestamp() - last);
            last = GetNowTimestamp();
            return time;
        }
    }
}
